<?php
// 接收前端参数把数据从数据库删除

$id = $_GET['id'];

$conn = mysqli_connect('localhost', 'root', 'root', 'main');/* 记得改这里？？？ */
mysqli_query($conn, "set charset 'utf8'");
mysqli_query($conn, "set character set 'utf8'");

$sql = "delete from shop where id=$id";
$res = mysqli_query($conn, $sql);

if ($res) {
  echo json_encode(array(
    "code" => 200,
    "body" => array(
      "msg" => "删除商品成功"
    )
  ));
} else {
  echo json_encode(array(
    "code" => 201,
    "body" => array(
      "msg" => "网络错误，请重试"
    )
  ));
}

?>